import { defineStore } from 'pinia'
import axios from 'axios';
import mockAxios from '../plugins/mock_axios';
import _ from 'lodash';

const myaxios=mockAxios(axios);

export const useCounsellorStore = defineStore({

  id: 'counsellor',
  state: () => ({
    counsellor: {}//{id,name}
  }),
  getters: {
   // doubleCount: (state) => state.counter * 2
  },
  actions: {
/**
 * 根据id获取辅导员的完整信息
 * @param {*} id 辅导员ID
 */
    async fetchCounsellor(id){
      this.counsellor.id=id;
      myaxios.get(`/counsellor/${id}`,{ r: { id: 1, name: 'lxf' } }).then(r => {
        this.counsellor = r;
      })
    },


/**
 * @returns 所有班级考勤分数排行榜 [{clazzId:1,clazzName:'软件2202',score:100},{clazzId:2,clazzName:'软件2203',score:99}]
 */
    async fetchAttendScoreListOfClazzOrderByScoreDesc(){
      return myaxios.get(`/counsellor/attendScoreListOfClazzOrderByScoreDesc`,{r:
        [{clazzId:1,clazzName:'软件2202',score:100},{clazzId:2,clazzName:'软件2203',score:99}
        ]
      })
    },

/**
 * 获取所有考勤表，含缺勤学生个数，根据时间倒序排列返回
 * @returns 获取所有考勤表，含缺勤学生个数，根据时间倒序排列返回
 */
    async fetchAttendencesWithAbsentCountOrderByStartFromDesc(){
      return myaxios.get(`/counsellor/attendencesWithAbsentCountOrderByStartFromDesc`,{r:
        [{id:1,startFrom:230211206,hours:3,courseName:'算法',courseId:1,clazzId:1,clazzName:'软件2202',state:'已确认',absentCount:1}
        ,{id:2,startFrom:230211210,hours:3,courseName:'算法',courseId:2,clazzId:2,clazzName:'软件2203',state:'已归档',absentCount:2}
      ]})
    },


    async archiveAttend(attendId){
      return myaxios.post(`/counsellor/archive/{{attendId}}`,{r:
        {id:1}});
    }

  }
})
